# -*- coding: utf-8 -*-

from mock import Mock

from google.appengine.ext import db
from google.appengine.api.namespace_manager import set_namespace

from flask import request, g
from dicthash.utils import Bunch
from dicthash.for_testing import TestGoogleDataStore

import lenta.code.views.lenta as lenta_views
import lenta.code.views.note as note_views
import lenta.code.views.tag as tag_views
import lenta.code.backends.working.models as models
    
    
class TestViewsBase(TestGoogleDataStore):
    """ """
    def setUp(self):
        super(TestViewsBase, self).setUp()
        models.request = lenta_views.request = note_views.request = tag_views.request = self.request_mock = Mock()
        models.g = lenta_views.g = note_views.g = tag_views.g = self.g_mock = Mock()
        # session user
        #self.user_key = db.Key.from_path('User', "testusername")
        #self.g_mock.user = Bunch(key=self.user_key)
        # namespace
        #self.namespace = str(self.user_key.name())
        self.namespace = "testusername"
        set_namespace(self.namespace)
                
    def tearDown(self):
        models.request = lenta_views.request = note_views.request = tag_views.request = request
        models.g = lenta_views.g = note_views.g = tag_views.g = g        